<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/templateDefault.xhtml">
        <ui:define name="title"><h:outputText value="#{msg.header_fornecedor_lbl}"/></ui:define>

        <ui:define name="content">
            <rich:panel header="#{msg.header_fornecedor_lbl}">
                <h:form id="entidadeForm" prependId="false">

                    <h:panelGrid columns="2" id="formGrid">
                        <h:outputLabel for="nome" value="#{msg.campo_nome}"/>
                        <h:inputText id="nome" value="#{fornecedorMB.modelo.nome}" size="44">
                            <a4j:ajax event="focus" render="res"/>
                        </h:inputText>
                        <h:outputLabel for="comboPai" value="#{msg.campo_pais}"/>
                        <h:selectOneMenu style="width: 247px" id="comboPai" value="#{provinciaMB.modeloTemp.idPais}" title="Países">
                            <a4j:ajax execute="@this" immediate="true" render="comboFilho res"/>
                            <f:selectItems value="#{paisMB.todosCombo}" var="varItem" itemValue="#{varItem.id}" itemLabel="#{varItem.nome}"/>
                        </h:selectOneMenu>
                        <h:outputLabel for="comboFilho" value="#{msg.campo_cidade}"/>
                        <h:selectOneMenu style="width: 247px" id="comboFilho" value="#{fornecedorMB.modelo.idProvincia}" title="Provincias/Cidades">
                            <a4j:ajax event="focus" render="res"/>
                            <f:selectItems value="#{provinciaMB.bySelectedPais}" var="varItem" itemValue="#{varItem.id}" itemLabel="#{varItem.nome}"/>
                        </h:selectOneMenu>
                        <h:outputLabel for="endereco" value="#{msg.campo_endereco}"/>
                        <h:inputText id="endereco" value="#{fornecedorMB.modelo.endereco}" size="44">
                            <a4j:ajax event="focus" render="res"/>
                        </h:inputText>
                        <h:outputLabel for="telefone" value="#{msg.campo_telefone}"/>
                        <h:inputText id="telefone" value="#{fornecedorMB.modelo.telefone}" size="44">
                            <a4j:ajax event="focus" render="res"/>
                        </h:inputText>
                        <h:outputLabel for="fax" value="#{msg.campo_fax}"/>
                        <h:inputText id="fax" value="#{fornecedorMB.modelo.fax}" size="44">
                            <a4j:ajax event="focus" render="res"/>
                        </h:inputText>
                        <h:outputLabel for="email" value="#{msg.campo_email}"/>
                        <h:inputText id="email" value="#{fornecedorMB.modelo.email}" size="44">
                            <a4j:ajax event="focus" render="res"/>
                        </h:inputText>
                        <h:outputLabel for="dataRegisto" value="#{msg.campo_data_registo}"/>
                        <h:inputText id="dataRegisto" value="#{fornecedorMB.modelo.dataRegisto}" size="44" readonly="true">
                            <f:convertDateTime dateStyle="short" type="date" pattern="dd-MM-yyyy"/>
                        </h:inputText>
                    </h:panelGrid>

                    <div align="center" style="width: 300px">
                        <a4j:commandButton execute="@form" title="#{msg.botao_gravar_lbl}" 
                                           action="#{fornecedorMB.salvar}" image="/imagens/save32x32.png" render="nome comboPai comboFilho endereco telefone email fax dataRegisto res"/>

                        <h:commandButton immediate="true" title="#{msg.botao_limpar}" image="/imagens/file32x32.png">
                            <f:ajax onevent="reset()"/>
                        </h:commandButton>
                    </div>     
                </h:form>
                <a4j:outputPanel id="res" style="width: 500px" ajaxRendered="true">
                    <rich:messages showDetail="true" id="msgs"/>
                </a4j:outputPanel>
            </rich:panel>
        </ui:define>
    </ui:composition>
</html>
